package com.srwl.mytx.widget.chatRow;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.srwl.mytx.R;
import com.srwl.mytx.Constant;
import com.srwl.mytx.domain.ImLatLng;
import com.srwl.mytx.activity.MapActivity;

public class ChatRowLocation extends BaseChatRow {


    private TextView locationView;
    private ImLatLng locBody;

    public ChatRowLocation(View itemView) {
        super(itemView);

    }

    @Override
    protected void onInflateView() {

    }

    @Override
    protected void onFindViewById(View itemView) {
        locationView = itemView.findViewById(R.id.tv_location);
    }


    @Override
    protected void onSetUpView() {
        locBody = JSONObject.parseObject( message.getContent(),ImLatLng.class);
        locationView.setText(locBody.getAddress());
        handleTextMessage();
    }

    @Override
    protected void onUpdateView() {

    }

    @Override
    protected void onBubbleClick() {
        Intent intent = new Intent(context, MapActivity.class);
        intent.putExtra("latitude", locBody.getLatitude());
        intent.putExtra("longitude", locBody.getLongitude());
        intent.putExtra("address", locBody.getAddress());
        activity.startActivity(intent);
    }

    protected void handleTextMessage() {


        if (!isSendMessage &&  message.getReadState()== Constant.MESSAGE_READ_STATE_UNREAD && chatRowCallBack != null) {

            //  message.setMsgReadStatus(2);
            chatRowCallBack.onMessageRead(message);

        }

    }



}
